package my.action.author;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;

import javax.servlet.http.*;

import my.controller.*;
import my.db.DAO.ArticleDAO;
import my.db.DAO.ArticleTypeDAO;
import my.db.DAO.AuthorDAO;
import my.db.DTO.ArticleDTO;
import my.db.DTO.ArticleTypeDTO;
import my.db.DTO.AuthorDTO;
public class AuthorUpdateAction implements  Action{
	 public ActionForward execute(HttpServletRequest request,HttpServletResponse response) throws Exception{			
		
		 //Fields
		 	ActionForward forward=new ActionForward();	
		 	AuthorDAO dao=new AuthorDAO();
		 	AuthorDTO dto=new AuthorDTO();
		 	boolean help=true;
		 	int id=Integer.parseInt(request.getParameter("author_id"));
		 	int gender=Integer.parseInt(request.getParameter("userGender"));
		 	
		// Initialized value to object author
		 	dto.setAuthorID(id); // author id
		 	dto.setAuthorGender(gender); // author gender
		 	dto.setAuthorName(request.getParameter("userName")); // author name
		 	dto.setAuthorMail(request.getParameter("userMail")); // author email
		 	dto.setAuthorPhone(request.getParameter("userPhone")); // author phone contact
		 	
		//Checking condition true or false
		 	help=dao.updateAuthor(dto); 
		 		if(help==true){// if update success
		 			forward.setPath("./list_author.article");// call action list_author
		 		}else{
		 			help=false;
		 		}
	  		return forward;
		}  	
}